package com.eaoa.uc.bustransfer.bo;

import java.util.Date;

import com.eaoa.base.EABaseBusinessObject;
import com.eaoa.dao.bus.BusTransferDAO;
import com.eaoa.vo.bus.BusTransfer;

public class BusTransferModifyBO extends EABaseBusinessObject{
	
	private static BusTransferDAO transferDAO = new BusTransferDAO();
	private BusTransfer vo ;
	private Long transferno;
	
	public BusTransferModifyBO(BusTransfer vo) {
		super();
		this.vo = vo;
	}

	protected void performBusinessLogic() {
		transferno = vo.getTransferno();
		
		if(transferno==null){
			
			vo.setIslock("N");
			vo.setCreator(getEmployee().getAccountno());
			vo.setCreatorname(getEmployee().getName());
			vo.setBillstatus("NEW");
			vo.setCreatdate(new Date());
			
			transferno = transferDAO.save(vo);
		}else{
			BusTransfer po =  (BusTransfer)transferDAO.loadAndLock(transferno);

			po.setTransferno(vo.getTransferno());
			po.setBillcode(vo.getBillcode());
			po.setBusVehicle(vo.getBusVehicle());
			po.setCost(vo.getCost());
			transferDAO.update(po);
		}
	}
	
	public Long getTransferno(){
		return transferno;
	}
}
